package com.gticket.customerbackend.mapper;

import com.gticket.customerbackend.pojo.Orders;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;
import java.util.List;

@Repository
public interface OrderMapper {

    //根据时间查询所有订单
    @Select("SELECT  order_id,order_state,user_name,cinema_name,create_time,totalPrice\n" +
            "FROM   ${database}.orders orders,${database}.cinema cinema,${database}.users users\n" +
            "WHERE   orders.user_id=users.user_id and cinema.cinema_id=orders.cinema_id \n" +
            "and  orders.flag=0 \n"+
            "and DATE_FORMAT(orders.create_time,'%Y-%m-%d')=#{create_time}" )
    List<Orders> listAllOrders(Orders orders);

    //根据创建时间和订单状态查询
    @Select("SELECT  order_id,order_state,user_name,cinema_name,create_time,totalPrice\n" +
            "FROM   ${database}.orders orders,${database}.cinema cinema,${database}.users users \n" +
            "WHERE   orders.user_id=users.user_id and cinema.cinema_id=orders.cinema_id \n" +
            "and order_state=#{order_state}\n"+
            "and  orders.flag=0 \n"+
            "and DATE_FORMAT(orders.create_time,'%Y-%m-%d')=#{create_time}" )
    List<Orders> listOrdersByState(Orders orders);



}
